package com.itheima.并发工具类.ConcurrentHashMap;

import java.util.concurrent.ConcurrentHashMap;

public class MyConcurrentHashMap {
    public static void main(String[] args) throws InterruptedException {
        ConcurrentHashMap<String,String> ch = new ConcurrentHashMap<>();
        new Thread(()->{
            for (int i = 0; i < 25; i++) {
                ch.put(i+"",i+"");
            }
        }).start();
        new Thread(()->{
            for (int i = 25; i < 51; i++) {
                ch.put(i+"",i+"");
            }
        }).start();
        //为了t1和t2能把数据全部添加完毕
        Thread.sleep(1000);
        for (int i = 0; i < 51; i++) {
            System.out.println(ch.get(i+""));
        }
    }

}
